package com.hotdog.service;

import com.alipay.api.AlipayApiException;
import com.hotdog.config.PayConfig;
import com.hotdog.feign.LogsPayFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.UUID;
/**
 * @author 郭鲁政
 */
@Service
public class PayUserServiceImpl implements PayUserService{
    @Autowired
    private PayConfig payConfig;
    @Autowired
   private LogsPayFeignClient logsPayFeignClient;
    @Override
    @Transactional
    public String getPayInfo(String orderid) throws AlipayApiException {

        String geturl = payConfig.geturl(orderid);
        if (geturl==null||geturl.length()<20){
            return null;
        }
        return geturl;
    }

    @Override
    public void logs() {
        String username = SecurityContextHolder.getContext().getAuthentication().getName();

        logsPayFeignClient.logs(username,"pay");
    }
}
